package agentspeakeditor.editors.common.scanner;

import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;

import agentspeakeditor.editors.ColorManager;
import agentspeakeditor.editors.IASLColorConstants;

public class ASLScanner extends RuleBasedScanner {

	public ASLScanner(ColorManager manager) {
		IToken mcomment =
			new Token(
				new TextAttribute(
					manager.getColor(IASLColorConstants.MCOMMENT)));
		
		IToken scomment =
				new Token(
					new TextAttribute(
						manager.getColor(IASLColorConstants.SCOMMENT)));
		
		IToken token =
				new Token(
					new TextAttribute(
						manager.getColor(IASLColorConstants.DEFAULT)));
	

	
		IRule[] rules = new IRule[5];
		
		rules[0] = new EndOfLineRule("//", scomment);
		rules[1] = new MultiLineRule("/*", "*/", mcomment);
		rules[2] = new SingleLineRule("!", ".", token);
		rules[3] = new MultiLineRule("+", ".", token);	
		rules[4] = new MultiLineRule("-", ".", token);
				
		setRules(rules);
	}
}